{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "net = Network(notebook =True, directed = True)\n",
    "subs1=list(set(sublist[0],for sublist in svos))\n",
    "subs2=list(set(sublist[2],for sublist in svos))\n",
    "create_node(net,subs1,subs2)\n",
    "dic_node_id =create_node_id_dic(net)\n",
    "create_network(net,svos,dic_node_id)\n",
    "net.show('my_network.html')\n",
    "def find_similar_semantics(net,node_id_dic,target_node):\n",
    "    target_node_id=node_id_dic[target_node]\n",
    "    adjcent_nodes=net.neighbors(target_node_id)\n",
    "    similar_semantics=[node_id_dic_inverse[node_id] for node_id in adjacent_nodes]\n",
    "    return similar_semantics\n",
    "node_id_dic_inverse={v:k for k, b in dic_node_id.items()}\n",
    "similar=find_similar_semantics(net,dic_node_i,'苏轼')\n",
    "print('与目标词苏轼语义相关的词',similar)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
